package weeek11.topic06;

import redis.clients.jedis.Jedis;

import java.util.Set;

/**
 * @author lfy
 */
public class JedisTest {
    public static void main(String[] args) {
        String host = "127.0.0.1";
        int port = 6379;
        Jedis jedis = new Jedis(host,port);
        //String类型的操作
        jedis.set("key","value");
        String value = jedis.get("key");
        System.out.println("String read:"+value);

        //list类型的操作

        jedis.lpush("list_key","list_v1","list_v2");
        jedis.lpush("list_key","list_v1","list_v2");

       while (jedis.llen("list_key")>0){
           String val = jedis.rpop("list_key");
           System.out.println("list read:"+val);
       }


       //zset 类型操作
        jedis.zadd("zset_key",1,"zset_1");
        jedis.zadd("zset_key",2,"zset_2");
        jedis.zadd("zset_key",3,"zset_3");

        Set<String> zset = jedis.zrange("zset_key", 0, 5);
        System.out.println(zset);


    }


}
